package com.kasax.android.arch.base.mvp;

import com.kasax.android.arch.base.ui.BaseCompatActivity;

public abstract class BaseMvpActivity<T extends BasePresenter, V extends IBaseView> extends BaseCompatActivity {
    protected T mPresenter;

    @Override
    protected void injectBeforeInitView() {
        super.injectBeforeInitView();
        // 由activity创建presenter
        mPresenter = generatePresenter();
        mPresenter.attachView((V) this);
    }

    protected abstract T generatePresenter();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.detachView();
        }
    }

}
